package com.example.android.commitcontent.ime.database.hanzi;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.Nullable;

public class HanziStatisticsDatabase extends SQLiteOpenHelper {

    private static int version = 1;
    private static final String name = "hanzi_database";

    public HanziStatisticsDatabase(@Nullable Context context) {
        super(context, name, null, version);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(String.format("create table %s (%s int primary key,%s varchar(50),%s varchar(50),%s varchar(50),%s varchar(50),%s int,%s varchar(50),%s int)",
                HanZiStatisticsTable.HanZiLetterTable.TABLE_NAME,
                HanZiStatisticsTable.HanZiLetterTable.Columns.ID,
                HanZiStatisticsTable.HanZiLetterTable.Columns.HANZI,
                HanZiStatisticsTable.HanZiLetterTable.Columns.SHENG_MU,
                HanZiStatisticsTable.HanZiLetterTable.Columns.YUN_MU,
                HanZiStatisticsTable.HanZiLetterTable.Columns.PIN_YIN,
                HanZiStatisticsTable.HanZiLetterTable.Columns.BI_HUA,
                HanZiStatisticsTable.HanZiLetterTable.Columns.BI_SHUN,
                HanZiStatisticsTable.HanZiLetterTable.Columns.REPEAT_COUNT
        ));
        sqLiteDatabase.execSQL(String.format("create table %s (%s int primary key,%s varchar(50),%s varchar(50),%s varchar(50),%s int)",
                HanZiStatisticsTable.HanZiWordsTable.TABLE_NAME,
                HanZiStatisticsTable.HanZiWordsTable.Columns.ID,
                HanZiStatisticsTable.HanZiWordsTable.Columns.HANZI_WORD,
                HanZiStatisticsTable.HanZiWordsTable.Columns.PIN_YIN,
                HanZiStatisticsTable.HanZiWordsTable.Columns.PIN_YIN_SIMPLIFIED,
                HanZiStatisticsTable.HanZiWordsTable.Columns.REPEAT_COUNT
        ));
        sqLiteDatabase.execSQL(String.format("create table %s (%s int primary key,%s varchar(50),%s varchar(50),%s varchar(50),%s varchar(50),%s int,%s varchar(50))",
                HanZiStatisticsTable.HanZiTable.TABLE_NAME,
                HanZiStatisticsTable.HanZiTable.Columns.ID,
                HanZiStatisticsTable.HanZiTable.Columns.HANZI,
                HanZiStatisticsTable.HanZiTable.Columns.SHENG_MU,
                HanZiStatisticsTable.HanZiTable.Columns.YUN_MU,
                HanZiStatisticsTable.HanZiTable.Columns.PIN_YIN,
                HanZiStatisticsTable.HanZiTable.Columns.BI_HUA,
                HanZiStatisticsTable.HanZiTable.Columns.BI_SHUN
        ));
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
